﻿using System.Collections.Generic;
using Bdcs.Application.Mappers.Dto;
using Bdcs.Application.Services;
using Bdcs.Application.Services.IServices;
using Bdcs.Core.Entity;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;

namespace Bdcs.Application.Controllers
{
    [ApiDescriptionSettings("围栏时段接口@101")]
    public class RouteTimeController : IDynamicApiController
    {
        // service层对象
        private readonly IRouteTimeService _routeTimeService;

        /// <summary>
        /// 注入service层
        /// </summary>
        /// <param name="routeTimeService"></param>
        public RouteTimeController(RouteTimeService routeTimeService)
        {
            _routeTimeService = routeTimeService;
        }

        /// <summary>
        /// 围栏时间段-分页查询
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="userId">用户id</param>
        /// <returns>分页数据</returns>
        public PagedList<RouteTimeDto> List(int pageIndex, int pageSize,string userId)
        {
            // 请求列表
            return _routeTimeService.List(pageIndex,pageSize,userId);
        }

        /// <summary>
        /// 新增围栏时段 opmode=1为update
        /// </summary>
        /// <param name="routeTimeInput"></param>
        /// <returns></returns>
        public int Add(RouteTimeInput routeTimeInput)
        {
            return _routeTimeService.Add(routeTimeInput);
        }

        /// <summary>
        /// 删除围栏时段
        /// </summary>
        /// <param name="Rkey"></param>
        /// <returns></returns>
        public DevRouteTimeMod Delete(string rkey)
        {   
            return _routeTimeService.delete(rkey);
        }
        
        /// <summary>
        /// 围栏时间段绑定设备
        /// </summary>
        /// <param name="rkey">围栏的主键id</param>
        /// <param name="devList">设备列表(用逗号拼接)</param>
        public int SaveBindDev(string rkey,string devList)
        {
            return _routeTimeService.SaveBindDev(rkey,devList);
        }

        /// <summary>
        /// 获取给定围栏所绑定的设备列表
        /// </summary>
        /// <param name="rkey">围栏时段的id</param>
        /// <returns></returns>
        public string GetDevChecked(string rkey)
        {
            return _routeTimeService.GetDevChecked(rkey);
        }
        
    }
}